<?php $CI =& get_instance();?>
<script>
APP = $merge(APP, {
	base: '<?php echo site_url(array('users',$usrAlias,'bap'))?>',
	utils: '<?php echo site_url(array('utils'))?>'
});
</script>
<?php 
	//create status signed, if already signed
	$CI->load->model('bap_model');
	$CI->load->model('bap_sign_model');
	$hasSigned = $CI->bap_model->is_signed_by_witnesses($bapData['bap_id']);
?>
<h2 style="border-bottom: 1px solid #ccc;">
Laporan Perbuatan :: 
<?php echo $perbData['perb_id']?> 
[Counter Approved]
</h2>

<h3 style="padding-bottom: 5; margin-bottom: 0; display: inline;">
	<span id="perbuatanView_icon">-</span> 
	<a id="perbuatanView_button" style="cursor: pointer; color: black" onclick="APP.slide.perbuatanView.toggle()">Laporan Perbuatan</a>
</h3>
<div id="perbuatanView">
<h4 style="padding-bottom: 5; margin-bottom: 0; padding-left: 10px ">Pelapor</h4>
<table cellpadding="5" style="margin-left: 5px" cellspacing="0" width="100%">
<?php if ($laporData['lapor_nik']):?>
<tr>
	<td>NIK:</td>
	<td colspan="2"><?php echo $laporData['lapor_nik']?></td>
</tr>
<?php endif;?>
<tr>
	<td width="20%">Nama:</td>
	<td colspan="2"><?php echo $laporData['lapor_nama']?></td>
</tr>
<tbody id="noPelaporID" style="display: table-row-group; ">
<?php if ($laporData['lapor_nik']): ?>
<?php $CI->load->model('pelapor_alamat_model')?>
<?php $alamat = $CI->pelapor_alamat_model->select_by_pelapor($laporData['lapor_id'])?>
<?php foreach ($alamat->result_array() as $row):?>
<tr>
	<td>Alamat:</td>
	<td width="40%"><?php echo $row['lapor_alm_alamat']?></td>
	<td valign="top"><?php echo $row['lapor_alm_kota']?></td>
</tr>
<?php endforeach;?>
<?php $CI->load->model('pelapor_telepon_model')?>
<?php $tlp = $CI->pelapor_telepon_model->select_by_pelapor($laporData['lapor_id'])?>
<?php foreach($tlp->result_array() as $row):?>
<tr>
	<td>Telepon:</td>
	<td><?php echo $row['lapor_tlp_no']?>
	</td>
</tr>
<?php endforeach;?>
<?php endif;?>
</tbody>
</table>

<h4 style="padding-bottom: 5; margin-bottom: 0; padding-left: 10px ">Perbuatan</h4>
<table cellpadding="5" style="margin-left: 5px" cellspacing="0" width="100%">
<tr>
	<td width="20%">Tanggal Lapor:</td>
	<td><?php echo $perbData['perb_tgl_lapor']?></td>
</tr>
<tr>
	<td>Tanggal Kejadian:</td>
	<td><?php echo $perbData['perb_tgl_kejadian']?></td>
</tr>
<tr>
	<td>Tempat Kejadian:</td>
	<td><?php echo $perbData['perb_tempat_kejadian']?></td>
</tr>
<tr>
	<td valign="top"><div style="padding-top: 2px">Kategori Perbuatan:</div></td>
	<td><?php echo $deperbData[0]['detachiev_nama']?>
	</td>
</tr>
<tr>
	<td width="50px">Jenis:</td>
	<td><?php echo $jenis_options[$deperbData[0]['achiev_jenis']]?></td>
</tr>
<tr>
	<td>Bidang:</td>
	<td><?php echo $deperbData[0]['achiev_bidang']?></td>
</tr>
<tr>
	<td>Tingkat:</td>
	<td><?php echo $tingkat_options[$deperbData[0]['detachiev_tingkat']]?></td>
</tr>
<tr>
	<td>Karyawan Pelaku:</td>
	<td>
		<?php $TMP = (array)$CI->karyawan_model->select_by_id($deperbData[0]['kary_id'])->row()?>
		<?php echo $TMP['kary_nama']?>
		<?php foreach ($CI->karyawan_history_jabatan_model->select_by_id($deperbData[0]['kary_jbt_id'])->result_array() as $row):?>
			<?php if ($row['kary_jbt_id']==$deperbData[0]['kary_jbt_id']) echo $row['jbt_nama']." [".$row['dep_nama']."]"?>
		<?php endforeach;?>
	</td>
</tr>
<?php
$ind=1;
foreach($deperbData as $pelaku):
if ($pelaku['kary_id'] == $deperbData[0]['kary_id']) continue; //skip the first index 
?>
<tr>
	<td></td>
	<td>
		<?php $TMP = (array)$this->karyawan_model->select_by_id($pelaku['kary_id'])->row()?>
		<?php echo $TMP['kary_nama']?>
		<?php foreach ($CI->karyawan_history_jabatan_model->getActive($pelaku['kary_id'])->result_array() as $row):?>
			<?php if ($pelaku['kary_jbt_id']==$row['kary_jbt_id']) echo $row['jbt_nama']." [".$row['dep_nama']."]"?>
		<?php endforeach;?>
	</td>
</tr>
<?php endforeach?>
<tr>
	<td valign="top"><div style="padding-top: 2px" >Keterangan:</div></td>
	<td><?php echo trim($perbData['perb_keterangan'])?></td>
</tr>
<tr>
	<td valign="top"><div style="padding-top: 2px">Bukti:</div></td>
	<td>
		<div class="fcUpload"> 
		<ul class="fcUpload-list">
			<?php foreach($buktiperbData as $bukti):?>
			<li class="file " id="file-1" style="background-color: transparent; ">
				<a class="file-title fakeLink" onclick="showImage(
					'<?php echo $bukti['perb_dok_file_name'] ?>',
					'<?php echo $bukti['perb_dok_file_name']?>',
					APP.base+'/ajax/loadImage/<?php echo $bukti['perb_dok_id']?>')">
					<?php echo $bukti['perb_dok_file_name']?>
				</a>
				<span class="file-size"><?php echo number_format($bukti['perb_dok_file_size']/1024,2)." kB"?></span>
			</li>
			<?php endforeach?>
		</ul> 
	</div> 
 	</td>
</tr>
</table>
</div>

<h3 style="padding-bottom: 5; margin-bottom: 0; padding-top: 20px">
	<span id="notificationView_icon">-</span> 
	<a id="notificationView_button" style="cursor: pointer; color: black" onclick="APP.slide.notificationView.toggle()">Approve Notification</a>
</h3>
<div id="notificationView">
<input type="hidden" name="inp[RE][0]" value="<?php echo $perbData['perb_id']?>" />

<?php $CI->load->model('bap_model')?>
<?php $bapData = (array)$CI->bap_model->select_by_perbID($perbData['perb_id'])->row()?>
<table cellpadding="5" width="100%">
<tr>
	<td width="20%">Tgl pembuatan :</td>
	<td><?php echo $bapData['bap_tgl']?></td>
</tr>
<tr>
	<?php $CI->load->model('karyawan_model')?>
	<?php $karyData = (array)$CI->karyawan_model->select_by_id($bapData['bap_pembuat_kary_id'])->row()?>
	<td>Oleh :</td>
	<td><?php echo $karyData['kary_nama']?></td>
</tr>
<tr>
	<?php $CI->load->model('jabatan_model')?>
	<?php $jbtData = (array)$CI->karyawan_history_jabatan_model->select_by_id($bapData['bap_pembuat_kary_jbt_id'])->row()?>
	<td>Jabatan :</td>
	<td><?php echo $jbtData['jbt_nama']?> [<?php echo $jbtData['dep_nama']?>]</td>
</tr>
<tr>
	<td colspan="2">
		<div style="border: 1px solid #CCC; padding: 10px"><?php echo $bapData['bap_pembuat_keterangan']?></div>
	</td>
</tr>
</table>
</div>

<h3 style="padding-bottom: 5; margin-bottom: 0; padding-top: 20px">
	<span id="counterView_icon">-</span> 
	<a id="counterView_button" style="cursor: pointer; color: black" onclick="APP.slide.counterView.toggle()">Counter Request</a>
</h3>
<div id="counterView">
<?php $CI->load->model('bap_sanggahan_model')?>
<?php $bapSanggahanData = (array)$CI->bap_sanggahan_model->select_by_id($bapData['bap_id'])->row()?>
<table cellpadding="5" width="100%">
<tr>
	<td width="20%">Tgl pembuatan :</td>
	<td><?php echo $bapSanggahanData['bap_sanggahan_tgl']?></td>
</tr>
<tr>
	<?php $CI->load->model('karyawan_model')?>
	<?php $karyData = (array)$CI->karyawan_model->select_by_id($bapSanggahanData['bap_sanggahan_pembuat_kary_id'])->row()?>
	<td>Oleh :</td>
	<td><?php echo $karyData['kary_nama']?></td>
</tr>
<tr>
	<?php $CI->load->model('jabatan_model')?>
	<?php $jbtData = (array)$CI->karyawan_history_jabatan_model->select_by_id($bapSanggahanData['bap_sanggahan_pembuat_kary_jbt_id'])->row()?>
	<td>Jabatan :</td>
	<td><?php echo $jbtData['jbt_nama']?> [<?php echo $jbtData['dep_nama']?>]</td>
</tr>
<tr>
	<td colspan="2">
		<div style="border: 1px solid #CCC; padding: 10px"><?php echo $bapSanggahanData['bap_sanggahan_keterangan']?></div>
	</td>
</tr>
<tr>
	<td valign="top"><div style="padding-top: 2px">Bukti:</div></td>
	<td>
		<div class="fcUpload"> 
		<ul class="fcUpload-list">
			<?php $CI->load->model('bap_sanggahan_bukti_model')?>
			<?php $bapSanngahanBuktiData = $CI->bap_sanggahan_bukti_model->select_by_bap($bapData['bap_id'])?>
			<?php foreach($bapSanngahanBuktiData->result_array() as $bukti):?>
			<li class="file " id="file-1" style="background-color: transparent; ">
				<a class="file-title fakeLink" onclick="showImage(
					'<?php echo $bukti['bap_bukti_file_name'] ?>',
					'<?php echo $bukti['bap_bukti_file_name']?>',
					APP.base+'/ajax/loadImage/<?php echo $bukti['bap_bukti_id']?>')">
					<?php echo $bukti['bap_bukti_file_name']?>
				</a>
				<span class="file-size"><?php echo number_format($bukti['bap_bukti_file_size']/1024,2)." kB"?></span>
			</li>
			<?php endforeach?>
		</ul> 
	</div> 
 	</td>
</tr>
</table>
</div>



<h3 style="padding-bottom: 5; margin-bottom: 0; padding-top: 20px">
	<span id="counterOuterView_icon">-</span> 
	<a id="counterOuterView_button" style="cursor: pointer; color: black">
		Counter <?php echo $bapSanggahanData['bap_sanggahan_status']=="AP"?"Approved":"Rejected"?> Notification
	</a>
</h3>
<div id="counterOuterView">
<table cellpadding="5" width="100%">
<tr>
	<td width="20%">Tgl pembuatan :</td>
	<td><?php echo $bapSanggahanData['bap_sanggahan_status_change']?></td>
</tr>
<tr>
	<?php $CI->load->model('karyawan_model')?>
	<?php $karyData = (array)$CI->karyawan_model->select_by_id($bapSanggahanData['bap_sanggahan_status_kary_id'])->row()?>
	<td>Oleh :</td>
	<td><?php echo $karyData['kary_nama']?></td>
</tr>
<tr>
	<?php $CI->load->model('jabatan_model')?>
	<?php $jbtData = (array)$CI->karyawan_history_jabatan_model->select_by_id($bapSanggahanData['bap_sanggahan_status_kary_jbt_id'])->row()?>
	<td>Jabatan :</td>
	<td><?php echo $jbtData['jbt_nama']?> [<?php echo $jbtData['dep_nama']?>]</td>
</tr>
<tr>
	<td colspan="2">
		<div style="border: 1px solid #CCC; padding: 10px"><?php echo $bapSanggahanData['bap_sanggahan_status_keterangan']?></div>
	</td>
</tr>
</table>
</div>

<div style="border-top:1px solid #ccc; text-align: center; padding-top: 10px; margin-top: 20px">
	<input type="button" value="Cancel" class="button" onclick="document.location=APP.base" />
</div>